<?php
namespace app\common\model;

use think\Model;

class AppLoginError extends BaseModel {
    public function add($data) {
        $data['status'] = 0;
        $this->save($data);
        return $this->username;
    }
    
    public function updateById($data, $id) {
        // allowField 过滤data数组中非数据表中的数据
        return $this->allowField(true)->save($data, ['username'=>$id]);
    }
    
    public function deleteByUsername($data) {
        $list = $this->where('username', '=', $data)->select();
        if(count($list) > 0) {
           for($i=0; $i<count($list); $i++){
               $id = $list[$i]['id'];
               $this->get($id)->delete();
           }
       }
    }
}